const localData = JSON.parse(localStorage.getItem("auth") || "{}");

const initialState = {
    userInfo: localData,
    messageNum: 8,
};
interface actionProps {
    type: string;
    payload?: any;
}

const userReducer = (state = initialState, action: actionProps) => {
    switch (action.type) {
        case 'TOGGLE_USERINFO':
            return {
                ...state,
                userInfo: action.payload,
            };
        case "TOOGLE_MESSAGE_NUM":
            return {
                ...state,
                messageNum: action.payload,
            }
        default:
            return state;
    }
};

export default userReducer;